var _ = require('lodash');
var scraper = require('./scraper.js');
var config = require('./config.js');
var rules = {
    level1: new RegExp('^http://www.adsoftheworld.com/media/print\\?rate=eiahkiBlwJVTQUk6WBg-5T6PvbVb32pCNj0i-iyusqQ&page=\\d+'),
    level2: new RegExp('^http://www.adsoftheworld.com/media/print/\\w{1,}'),
    level3: new RegExp('http://naotw-pd.s3.amazonaws.com/\\w{1,}.jpg')
}

//页面
var start = config.start;
var end = config.end;
var widthFirst = config.withFirst;

var urls = _.map(Array(end - start + 1), function(value, index) {
    if (index == 0 && widthFirst) {
        return "http://www.adsoftheworld.com/cards?terms=&created=all&medium=1&industry=All&country=All&sort_by=created";
    } else {
        return "http://www.adsoftheworld.com/cards?terms=&created=all&medium=1&industry=All&country=All&sort_by=created&page=" + (index + start - 1);
    }
});
urls = [ 'http://www.adsoftheworld.com/media/print/ramrod_pineapple_guy',
    'http://www.adsoftheworld.com/media/print/idont_dog_1',
    'http://www.adsoftheworld.com/media/print/wwf_switch',
    'http://www.adsoftheworld.com/media/print/tmz_rehab',
    'http://www.adsoftheworld.com/media/print/tmz_lindsay',
    'http://www.adsoftheworld.com/media/print/mercedes_green',
    'http://www.adsoftheworld.com/media/print/bp_bp_superwash',
    'http://www.adsoftheworld.com/media/print/mango_fashion_awards_donatella_versace',
    'http://www.adsoftheworld.com/media/print/toucan',
    'http://www.adsoftheworld.com/media/print/ballantines_lightbox',
    'http://www.adsoftheworld.com/media/print/colgate_palmolive_eliminate_premature_wrinkles',
    'http://www.adsoftheworld.com/media/print/el_tiempo_chavez',
    'http://www.adsoftheworld.com/media/print/gatorade_run',
    'http://www.adsoftheworld.com/media/print/on_the_go',
    'http://www.adsoftheworld.com/media/print/verbal_abuse_3',
    'http://www.adsoftheworld.com/media/print/absolut_limousine',
    'http://www.adsoftheworld.com/media/print/absolut_outdoor',
    'http://www.adsoftheworld.com/media/print/casa_claudia_chaise',
    'http://www.adsoftheworld.com/media/print/evonik_industries_sandbox',
    'http://www.adsoftheworld.com/media/print/canon_snake' ];
console.log(urls);
scraper.start(urls);